<template>
  <!--element-plus全局中文国际化-->
  <el-config-provider :locale="locale">
    <router-view />
    <!--回到顶部-->
    <el-backtop :right="50" :bottom="50" />
  </el-config-provider>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
// https://element-plus.org/zh-CN/guide/i18n.html
import { ElConfigProvider } from 'element-plus'
import zh from 'element-plus/lib/locale/lang/zh-cn'
import en from 'element-plus/lib/locale/lang/en'
import { useI18nStore } from '@/store/i18n'
import { useThemeStore } from '@/store/theme'
import { storeToRefs } from 'pinia'

/* element-plus全局国际化处理 */
const i18nStore = useI18nStore()
const locale = computed(() => {
  return i18nStore.locale === 'zh' ? zh : en
})

/* 刷新页面判断使用默认主题颜色 */
const themeStore = useThemeStore()
const { mainColor, fontColor, fontColorActive } = storeToRefs(themeStore)
themeStore.setDefaultColorAction()
</script>

<style lang="scss">
/* 定义全局类名 */
.main-color,
.a {
  color: v-bind(mainColor);
}
.main-color-bg {
  background-color: v-bind(mainColor);
}
.font-color {
  color: v-bind(fontColor);
}
.font-color-active {
  color: v-bind(fontColorActive);
}

/* 自定义nprogress顶部进度条颜色 */
#nprogress .bar {
  //background: #304156 !important;
}
</style>
